package com.apes.hr.group.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.hr.base.model.Employee;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：钉钉人员与erp人员关联表
 * @author ZhengZeXian
 * @create 2020年11月23日10:48:22
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = DingDingPerson.CONST_TABLE_NAME)
public class DingDingPerson extends Model {

    public static final String CONST_TABLE_NAME = "hr_ding_ding_person";

    @Id
    @Column(name = "id", nullable = false, length = 120)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "钉钉人员关联")
    @Comment("编码")
    private String id; //编码

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "employee_id", referencedColumnName = "id")
    @Comment("人员编码")
    private Employee employee; //人员编码

    @Name
    @Column(name = "ding_ding_user_id", length = 500)
    @Comment("钉钉用户ID")
    private String dingDingUserId; //钉钉用户ID

    @Column(name = "execute", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("执行标识")
    private boolean execute = false;  //是否执行过删除钉钉ID操作

    //入职申请单单号
    @Transient
    private String entryId;
    //调动申请单号
    @Transient
    private String transferId;
    //钉钉部门群标记
    @Transient
    private Boolean deptSign = false;
    //钉钉考勤组标记
    @Transient
    private Boolean groupSign = false;
}
